package com.celan.year2023.month05.day20;

import java.util.Arrays;

/**
 * @author Celan
 * @description TODO
 */
class Solution {
    public int storeWater(int[] bucket, int[] vat) {
        int sum = 0;
        for (int a : vat) {
            sum += a;
        }
        if (sum == 0) {
            return 0;
        }
        int ans = Integer.MAX_VALUE, n = vat.length;
        for (int i = 1; i <= sum; i++) {
            //需要蓄水i次
            int count = 0;
            for (int j = 0; j < n; j++) {
                count += Math.max(0, (vat[j] - 1) / i - bucket[j] + 1);
            }
            ans = Math.min(ans, count + i);
        }
        return ans;
    }
}
